package com.hundun.hddeal.response;


import com.hundun.hddeal.enums.ResultEnum;

import java.util.Map;

/**
 * 通用返回信息
 */
public class ResultUtil {



    public static <T> Result<T> success() {
        return new Result<T>(null);
    }

    public static Result success(Map map) {
        return new Result(map);
    }




    /** 操作失败 */
    public static <T> Result<T> FAIT() {
        return new Result<>(ResultEnum.FAIT.getCode(), ResultEnum.FAIT.getMessage());
    }

    public static <T> Result<T> success(String message) {
        return new Result<>(100, message);
    }

    public static <T> Result<T> ISOK(T data){
        return new Result<>(ResultEnum.ISOK.getCode(),ResultEnum.ISOK.getMessage(),data);
    }

    public static <T> Result<T> ISNULL(T data){
        return new Result<>(ResultEnum.ISNULL.getCode(),ResultEnum.ISNULL.getMessage(),data);
    }

    public static <T> Result <T> isok(T data){
        return new Result<>(data);
    }

    public static <T> Result <T> success(T data){
        return new Result<>(data);
    }

    public static <T> Result <T> success(T data,Double sum){
        return new Result<>(data,sum);
    }

    public static <T> Result<T> error(ResultEnum resultEnum) {
        return error(resultEnum.getCode(), resultEnum.getMessage());
    }

    public static <T> Result error(String message, T data, Double sum) {
        return new Result<>(ResultEnum.SERVICE_ERROR.getCode(), message, data,sum);
    }

    public static <T> Result<T> error(String message, T data) {
        return new Result<>(ResultEnum.SERVICE_ERROR.getCode(), message, data);
    }

    public static <T> Result<T> success(int code,String message, T data) {
        return new Result<>(ResultEnum.SUCCESS.getCode(), message, data);
    }

    public static <T> Result<T> error() {
        return new Result<>(ResultEnum.SERVICE_ERROR.getCode(), ResultEnum.SERVICE_ERROR.getMessage());
    }

    public static <T> Result<T> error(String message) {
        return new Result<>(0, message);
    }


    public static <T> Result<T> error(int code, String message) {
        return new Result<>(code, message);
    }


}
